﻿Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Data
Imports System.Windows.Forms
Imports DevComponents.DotNetBar.Controls
Imports DevComponents.Editors.DateTimeAdv
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.DTO
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.General
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.BUSS

Namespace DoAnQuanLyBanHang.DAO
    Public Class NhapHangCtrl
        Private m_NhapHangData As New NhapHangData()
        Private m_NhapHangInfo As New NhapHangInfo()

        Public Sub HienThiComboBox(cbx As ComboBox)
            Dim m_DT As DataTable = m_NhapHangData.LayNhapHang()
            cbx.DataSource = m_DT
            cbx.DisplayMember = "Tháng"
            cbx.ValueMember = "Tháng"
        End Sub
        Public Sub HienThiComboBox1(cbx As ComboBox)
            Dim m_DT As DataTable = m_NhapHangData.LayNhapHang()
            cbx.DataSource = m_DT
            cbx.DisplayMember = "Năm"
            cbx.ValueMember = "Năm"
        End Sub

        Public Shared Function LayDsNhapHangTheoThang(thang As Integer, nam As Integer) As IList(Of NhapHangInfo)
            Dim ds As IList(Of NhapHangInfo) = New List(Of NhapHangInfo)()

            Dim data As New NhapHangData()
            Dim tbl As DataTable = data.LayDSNhapHangTheoThang(thang, nam)

            Dim NhapHang As IList(Of NhapHangInfo) = New List(Of NhapHangInfo)()

            For Each row As DataRow In tbl.Rows
                Dim m_NCC As New NhaCungCapInfo()
                m_NCC.MaNCC = Convert.ToString(row("MaNCC"))
                m_NCC.DienThoai = Convert.ToString(row("DienThoai"))
                m_NCC.DiaChi = Convert.ToString(row("DiaChi"))
                Dim NH As New NhapHangInfo()
                NH.Tháng = Convert.ToInt32(row("Tháng"))
                NH.Năm = Convert.ToInt32(row("Năm"))
                NH.Tổng_Nhập = Convert.ToInt64(row("Tổng Nhập"))
                NH.GiaBan = Convert.ToInt64(row("GiaBan"))
                NH.DonGia = Convert.ToInt64(row("DonGia"))
                NH.SoLuong = Convert.ToInt64(row("SoLuong"))
                NH.NgayNhap = Convert.ToDateTime(row("NgayNhap"))
                NH.TenNCC = Convert.ToString(row("TenNCC"))
                NH.LoaiTien = Convert.ToString(row("LoaiTien"))
                NH.LoaiGD = Convert.ToString(row("TenLoaiGiaoDich"))
                NH.MaMH = Convert.ToString(row("MaMH"))
                NH.TenMH = Convert.ToString(row("TenMH"))
                NH.NCC = m_NCC
                NhapHang.Add(NH)
            Next
            Return NhapHang
        End Function
    End Class
End Namespace
